package com.senter.demo.common.misc;


import android.app.Activity;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;


public class ActivityHelper<TypeOfActivity extends Activity>
{
	private final TypeOfActivity ownersActivity;
	public ActivityHelper(TypeOfActivity activity) {
		ownersActivity=activity;
	}
	
	public final void showToastShort(final int text)
	{
		ownersActivity.runOnUiThread(new Runnable() {
			@Override
			public void run()
			{
				Toast.makeText(ownersActivity, text, Toast.LENGTH_SHORT).show();
			}
		});
	}
	public final void showToastShort(final String text)
	{
		ownersActivity.runOnUiThread(new Runnable() {
			@Override
			public void run()
			{
				Toast.makeText(ownersActivity, text, Toast.LENGTH_SHORT).show();
			}
		});
	}

	public final void showToastLong(final String text)
	{
		ownersActivity.runOnUiThread(new Runnable() {
			@Override
			public void run()
			{
				Toast.makeText(ownersActivity, text, Toast.LENGTH_LONG).show();
			}
		});
	}

	public final void showToastLong(final int text)
	{
		ownersActivity.runOnUiThread(new Runnable() {
			@Override
			public void run()
			{
				Toast.makeText(ownersActivity, text, Toast.LENGTH_LONG).show();
			}
		});
	}
	public TypeOfActivity activity(){return ownersActivity;}
	
	public final Button buttonWithClickListener(int id,View.OnClickListener onClickListener)
	{
		Button btn=(Button) ownersActivity.findViewById(id);
		btn.setOnClickListener(onClickListener);
		return btn;
	}
}